package gui;

import java.applet.Applet;
import java.applet.AudioClip;
import java.io.*;
import java.net.URL;

public class Sound // Holds one audio file
{

	private AudioClip song; // Sound player
	private URL songPath; // Sound path

	public Sound(String filename) {
		try {
			songPath = new URL("file", "", filename);
			// songPath = new URL(getCodeBase(),filename); // Get the Sound URL
			song = Applet.newAudioClip(songPath); // Load the Sound
		} catch (Exception e) {
		} // Satisfy the catch
	}

	public void playSound() {

		song.loop(); // Play
	}

	public void stopSound() {
		song.stop(); // Stop
	}

	public void playSoundOnce() {
		System.out.println("playing once" + songPath);
		song.play(); // Play only once
	}

	public void init() {
		Sound testsong = new Sound("song.mid");
		testsong.playSound();
	}
}